#ifndef CHART_MANAGER_H
#define CHART_MANAGER_H

#include <QObject>
#include <QtCharts/QChart>
#include <QtCharts/QBarSeries>
#include <QtCharts/QLineSeries>
#include <QtCharts/QPieSeries>
#include <QtCharts/QChartView>
#include <QtCharts/QBarSet>
#include <QtCharts/QValueAxis>
#include <QtCharts/QBarCategoryAxis>
#include <QBarSeries>
#include <QLineSeries>
#include <QPieSeries>
#include <QChartView>
#include <QBarSet>
#include <QSqlQuery>

class ChartManager : public QObject {
    Q_OBJECT

public:
    explicit ChartManager(QObject *parent = nullptr);
    
    // 销售统计图表
    QChart* createSalesChart(const QDate &startDate, const QDate &endDate);
    
    // 产品销量排行
    QChart* createProductSalesRankingChart(const QDate &startDate, const QDate &endDate);
    
    // 库存分布图表
    QChart* createInventoryDistributionChart();
    
    // 利润分析图表
    QChart* createProfitAnalysisChart(const QDate &startDate, const QDate &endDate);
    
    // 月度销售趋势
    QChart* createMonthlySalesTrendChart(int year);
    
private:
    QMap<QString, qreal> getSalesDataByDate(const QDate &startDate, const QDate &endDate);
    QMap<QString, int> getProductSalesRanking(const QDate &startDate, const QDate &endDate);
    QMap<QString, int> getInventoryDistribution();
    QMap<QString, QPair<qreal, qreal>> getProfitData(const QDate &startDate, const QDate &endDate);
    QMap<QString, qreal> getMonthlySalesData(int year);
};

#endif // CHART_MANAGER_H
